Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
prosemirror-splittable
Advanced tools
Extends ProseMirror's AttributeSpec to allow for splittable
property. splittable
is a boolean that, when true
, enables the inheritance of the attribute when splitting a node using the splitSplittableBlock
command.
In the schema defined below, the textAlign
attribute is defined as splittable
for both paragraph
and heading
nodes.
import { Schema } from 'prosemirror-model'
const schema = new Schema({
nodes: {
text: {},
paragraph: {
content: 'text*',
group: 'block',
attrs: {
textAlign: { default: 'left', splittable: true },
},
toDOM(node) {
return ['p', { style: `text-align: ${node.attrs.textAlign};` }, 0]
},
},
heading: {
content: 'text*',
group: 'block',
attrs: {
textAlign: { default: 'left', splittable: true },
},
toDOM(node) {
return ['h1', { style: `text-align: ${node.attrs.textAlign};` }, 0]
},
},
doc: { content: 'block*' },
},
})
Later, we can use the keymap
plugin to bind the Enter
key to the splitSplittableBlock
command.
import { splitSplittableBlock } from 'prosemirror-splittable'
import { keymap } from 'prosemirror-keymap'
import {
baseKeymap,
chainCommands,
createParagraphNear,
liftEmptyBlock,
newlineInCode,
} from 'prosemirror-commands'
const customBaseKeymap = {
...baseKeymap,
Enter: chainCommands(
newlineInCode,
createParagraphNear,
liftEmptyBlock,
splitSplittableBlock,
),
}
const plugin = keymap(customBaseKeymap)
MIT
FAQs
Inherit ProseMirror node attributes when splitting nodes.
The npm package prosemirror-splittable receives a total of 1,953 weekly downloads. As such, prosemirror-splittable popularity was classified as popular.
We found that prosemirror-splittable demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.